/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package homework6;

/**
 *
 * @author Administrator
 */
import java.util.*;
public class MainC{
    public static void main(String []args){
        int day[]={31,28,31,30,31,30,31,31,30,31,30,31};
        int year,days,i;
        String m,d;
        Scanner reader=new Scanner(System.in);
        while(reader.hasNext()){
            year=reader.nextInt();
            days=reader.nextInt();
            if((year%4==0&&year%100!=0)||(year%400==0))
                day[1]=29;
            else
                day[1]=28;
            for(i=0;days>day[i];i++){
                days -= day[i];
            }
            if(i+1<10) m="0"+(i+1);
            else m=""+(i+1); 
            if(days<10) d="0"+days;
            else d=""+days; 
            System.out.println(year+"-"+m+"-"+d);
        }
    }
}
